<input type="hidden" class="oldjob" >
<script type="text/javascript">
    var domain = "http://www.mxdxedu.cn";
    var bigJob = [];
    var job = [];
    var job2 = [];
    var smallJob = [];

    $("#post").click(function(){
    	$.ajax({
            type:"GET",
            url:domain+"/p/getRecruitmentDictList?type=1&parentIdisNull=1", //访问的链接
            dataType:"jsonp",  //数据格式设置为jsonp
            jsonp:"callback",  //Jquery生成验证参数的名称
            success:function(data){  //成功的回调函数
            	bigJob = data;
	            var html = "<ul>";
	            for(var i=0;i<bigJob.length;i++){
	                html += "<li class='bigJob' data="+bigJob[i].id+" style='cursor: pointer;' ><label>"+bigJob[i].name+"</label></li>";
	            }
	            html +="</ul>";
	            $(".choiceLst").html(html);
	            $("._btnAreaClear").attr("data",2);
	
	            //获取选中的值
	            var ids = $("#job").val();
                $(".oldjob").val(ids);
	            if(ids){
	                var jobArr = getString(ids,",");
	                var jobNames = $(".jobhtml").html();
	                var jobNameArr = getString(jobNames,",");
	                var choice = '';
	                for(var i=0;i<jobArr.length;i++){
	                    choice += '<li class="'+jobArr[i]+'"><label><input type="checkbox" class="popChkdeljob" data="'+jobNameArr[i]+'" value="'+jobArr[i]+'" checked="checked">'+jobNameArr[i]+'</label></li>';
	                }
	            }
	            $("#_selected").append(choice);
	            $(".dialogMask,.choice").show();
	        },
	        error: function (e) {
	        	console.log(e);
	        }
    	})
    })
    $(document).on("click", ".bigJob", function(){
        $(".jobul,.smalljobul").remove();
        var id = $(this).attr("data");//根据id去请求子类  假如得到的子类为cata
        
        $.ajax({
            type:"GET",
            url:domain+"/p/getRecruitmentDictList?type=1&parentId="+id, //访问的链接
            dataType:"jsonp",  //数据格式设置为jsonp
            jsonp:"callback",  //Jquery生成验证参数的名称
            success:function(data){  //成功的回调函数
	            job = data;
	            var html = "<ul class='jobul'>";
	            var ids = $("#job").val();
	            var jobArr = getString(ids,",");
	            for(var i=0;i<job.length;i++){
	                if(job[i].isLeaf == 0){
	                    html += "<li class='job' data="+job[i].id+" style='cursor: pointer;' ><label>"+job[i].name+"</label></li>";
	                }else{
	                    if($.inArray(job[i].id, jobArr)==-1){
	                        var check='';
	                    }else{
	                        var check='checked="checked"';
	                    }
	                    html += "<li class='job' data="+job[i].id+" style='cursor: pointer;' ><label><input type='checkbox' class='popChkjob job_"+job[i].id+"' name='job' "+check+" data_name="+job[i].name+" value="+job[i].id+" >"+job[i].name+"</label></li>";
	                }
	            }
	            html +="</ul>";
	            $(".choiceLst").append(html);
        	},
        	error: function (e) {
            	console.log(e);
            }
        })
    });
    $(document).on("click", ".job", function(){
        $(".smalljobul").remove();
        var id = $(this).attr("data");//根据id去请求子类  假如得到的子类为smallCata
        
        $.ajax({
            type:"GET",
            url:domain+"/p/getRecruitmentDictList?type=1&parentId="+id, //访问的链接
            dataType:"jsonp",  //数据格式设置为jsonp
            jsonp:"callback",  //Jquery生成验证参数的名称
            success:function(data){  //成功的回调函数
	            smallJob = data;
	            var html = "<ul class='smalljobul'>";
	            var ids = $("#job").val();
	            var jobArr = getString(ids,",");
	            for(var i=0;i<smallJob.length;i++){
	                if(smallJob[i].isLeaf == 0){
	                    html += "<li class='smalljob' data="+smallJob[i].id+" style='cursor: pointer;' ><label>"+smallJob[i].name+"</label></li>";
	                }else{
	                    if($.inArray(smallJob[i].id, jobArr)==-1){
	                        var check='';
	                    }else{
	                        var check='checked="checked"';
	                    }
	                    html += "<li class='smalljob' data="+smallJob[i].id+" style='cursor: pointer;' ><label><input type='checkbox'  class='popChkjob job_"+smallJob[i].id+"' name='smallcata' "+check+" data_name="+smallJob[i].name+" value="+smallJob[i].id+">"+smallJob[i].name+"</label></li>";
	                }
	            }
	            html +="</ul>";
	            $(".choiceLst").append(html);
	        },
	        error: function (e) {
	        	console.log(e);
	        }
        })
    });

    $(document).on("click", ".popChkjob", function(){
        var ids = $("#job").val();
        //console.log($(this).val());
        var id = $(this).val();
        //console.log($(this).attr("data_name"));
        var jobName = $(this).attr("data_name");
        var jobNames = $(".jobhtml").html();
        if($(this).prop("checked")){
            if(ids){
                var jobArr = getString(ids,",");
                jobArr = addKey(jobArr,id);
                if(!jobArr){
    				return false;
    			}
                $("#job").val(jobArr.join());

                var jobHtmlArr = getString(jobNames,",");
                jobHtmlArr = addKey(jobHtmlArr,jobName);
                $(".jobhtml").html(jobHtmlArr.join());
            }else{
                $("#job").val(id);
                $(".jobhtml").html(jobName);
            }
            $("#_selected").append('<li class="'+id+'"><label><input type="checkbox" class="popChkdeljob" data="'+jobName+'" value="'+id+'" checked="checked">'+jobName+'</label></li>');
        }else{
            var jobArr = getString(ids,",");
            jobArr = delkey(jobArr,id);
            $("."+id).remove();
            $("#job").val(jobArr.join());

            var jobHtmlArr = getString(jobNames,",");
            jobHtmlArr = delkey(jobHtmlArr,jobName);
            if(jobHtmlArr.join()==''){
                $(".jobhtml").html("请选择");
            }else{
                $(".jobhtml").html(jobHtmlArr.join());
            }
        }
    })
    $(document).on("click", ".popChkdeljob", function(){
        var id = $(this).val();
        var jobName = $(this).attr("data");
        var ids = $("#job").val();
        var jobArr = getString(ids,",");
        jobArr = delkey(jobArr,id);
        $("."+id).remove();
        $("#job").val(jobArr.join());
        $(".job_"+id).attr("checked",false);

        var jobNames = $(".jobhtml").html();
        var jobHtmlArr = getString(jobNames,",");
        jobHtmlArr = delkey(jobHtmlArr,jobName);
        if(jobHtmlArr.join()==''){
            $(".jobhtml").html("请选择");
        }else{
            $(".jobhtml").html(jobHtmlArr.join());
        }
    })
</script>